/*
 * Copyright (C) 2018 Zhejiang xiaominfo Technology CO.,LTD.
 * All rights reserved.
 * Official Web Site: http://www.xiaominfo.com.
 * Developer Web Site: http://open.xiaominfo.com.
 */

package com.lishiots.cloud.datacenter.middleware.config;

import com.lishiots.cloud.datacenter.middleware.common.SwaggerRoot;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMethod;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/***
 * Swagger配置
 * @since:datacenter-parent 1.0
 * @author <a href="mailto:xiaoymin@foxmail.com">xiaoymin@foxmail.com</a> 
 * 2018/08/13 15:36
 */
@Configuration
@EnableSwagger2
public class Swagger2Config extends SwaggerRoot {

    @Bean(value = "swaggerRestTourismResources")
    public Docket swaggerRestTourismResources() {
        ApiInfo touristApi = new ApiInfoBuilder()
                .title("中间件文档")
                .description("中间件文档")
                .termsOfServiceUrl("http://www.group.com/")
                .contact("group@qq.com")
                .version("1.0")
                .build();

        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(touristApi)
                .groupName("中间件文档")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.lishiots.cloud.datacenter.middleware"))
                .paths(PathSelectors.any())
                .build().globalResponseMessage(RequestMethod.POST,globalResponseMessageCode())
                .globalResponseMessage(RequestMethod.GET,globalResponseMessageCode());
    }


}
